
/*****************************************************************************
 *
 * 作   者: 马婷婷 * 创建时间: 2020/12/11 18:56:39 *
 * Copyright (C) 2008 - 鹏业软件公司
 *
 *****************************************************************************/

import {DataPacket, NorDataList} from 'pengesoft-ng-lib';
import {MyDepartments} from './mydepartments.domain';

/**
 * 部门树
 */
export class MyDepartment extends DataPacket {
  NodeId: number;
  ParentId: number;
  Leader: string;
  OnJobNum: number;
  DeptName: string;
  ChildDepartment: MyDepartments;

  constructor(options: {
    NodeId?: number;
    ParentId?: number;
    Leader?: string;
    OnJobNum?: number;
    DeptName?: string;
    ChildDepartment?: MyDepartments;
  } = {}) {
    super();
    this.NodeId = !options.NodeId ? 0 : Number.parseFloat(options.NodeId.toString());
    this.ParentId = !options.ParentId ? 0 : Number.parseFloat(options.ParentId.toString());
    this.Leader = options.Leader || '';
    this.OnJobNum = !options.OnJobNum ? 0 : Number.parseFloat(options.OnJobNum.toString());
    this.DeptName = options.DeptName || '';
    this.ChildDepartment = new MyDepartments(options?.ChildDepartment);
  }
}

/**
 * 部门树列表
 */
export class MyDepartmentList extends NorDataList<MyDepartment> {

  constructor(options: {
    _Items?: Array<MyDepartment>
  } = {}) {
    super();
    if (options._Items) {
      for (const item of options._Items) {
        this.append(new MyDepartment(item));
      }
    }
  }
}
